package com.cdn.treasure.controller;

import cn.hutool.core.collection.CollUtil;
import com.cdn.treasure.annotation.SensitiveDecode;
import com.cdn.treasure.annotation.SensitiveEncode;
import com.cdn.treasure.model.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author CaiDingNu
 * @desc
 * @date 2022/12/08 10:18
 */
@RestController
public class UserController {

    /**
     * 解密
     * @param user
     * @return
     */
    @GetMapping("decode")
    @SensitiveDecode(entity = User.class)
    public List<User> decode(User user ) {
        return CollUtil.newArrayList(user);
    }

    /**
     * 加密
     * @return
     */
    @GetMapping("encode")
    @SensitiveEncode(entity = User.class)
    public List<User> encode( ) {
        User user = new User();
        user.setName("zhangsan");
        user.setJob("DBA");
        return CollUtil.newArrayList(user);
    }

}
